function showSectionConfigSearch() {
	window.location.href = "showSectionConfigSearch.do";
}

function ajaxFindSectionConfigSearchList(currentPage,pageSize) {
	$.ajax({
		type : "post",
		url : "ajaxSectionConfigSearchList.do",
		data : {
			plateNum : $("#plateNum").val(),
			plateTypeId : $("#licencePlateKind").val(),
			vehicleTypeId : $("#vehicleType").val(),
		    ownername : $("#ownername").val(),
			effectiveStartTime : $("#effectiveStartTime").val(),
			effectiveEndTime : $("#effectiveEndTime").val(),
			currentPage:currentPage,
			pageSize:pageSize,
		},
		success : function(msg) {
			$("#listSectionConfigBox").html(msg);
		}
	});
}

function ajaxShowSectionConfigEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowSectionConfigEdit.do",
		data:{sectionConfigId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 740,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "保存",
				        	  click: function() {
				        		  ajaxSaveSectionConfig(this);
				        	  }
				          },
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxSaveSectionConfig(objDialog) {
	//sectionConfigValidate();
	if ($("#frmSectionConfig").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveSectionConfig.do",
				success: function (msg) {
					clearInput("#sltSectionConfig");
					ajaxFindSectionConfigSearchList();
					showMessageDialog("保存区间配置信息","区间配置信息保存成功。",null,dialogType.info);
				}
		};
		$("#frmSectionConfig").ajaxSubmit(options);
	}
}

function ajaxShowSectionConfigView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowSectionConfigView.do",
		data:{sectionConfigId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 740,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [ {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				} ]
			});
		}
	});
}

function ajaxDeleteSectionConfigById(id) {
	var sectionConfigIds="";
	var sltSC = $("#listSectionConfigList tbody input:checked").length;
	if(id==null){
		$("#listSectionConfigList tbody input:checked").each(function(){ 
			sectionConfigIds += $(this).val()+";";
		});
		if(sltSC == 0){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			sectionConfigIds = sectionConfigIds.substring(0, sectionConfigIds.length-1);
		} 
	}else{
		sectionConfigIds=id;
		sltSC = 1;
	}
	if( sectionConfigIds!=null){
		showMessageDialog("删除区间配置信息","确定要删除所选“"+sltSC+"”条区间配置信息记录吗？",
				function () {
			$.ajax({     
				type:"post",
				url:"ajaxDeleteSectionConfigByIds.do",
				data:{sectionConfigIds:sectionConfigIds},
				success:function(msg){
					ajaxFindSectionConfigSearchList();
					showMessageDialog("提示","区间配置信息删除成功",null,dialogType.info);
				}
			});
		}
		,dialogType.warning);
	}
}

//function sectionConfigValidate(){
//	$("#frmVehicleTravelStrategy").validate({
//		errorLabelContainer: $("#infoSectionConfig"),
//		rules : {
//			name : {
//				required :true				
//			},
//			signalLampStatusId : {
//				required :true				
//			}
//		},
//		messages : {
//			name : {
//				required :"请输入号牌号码！"
//			},
//			signalLampStatusId : {
//				required :"请输入信号灯状态！"
//			}
//		},
//		success: function(label) {
//			label.html("&nbsp;");
//		}
//	});
//}
